<template>
  <a-select
    :disabled="disabled"
    v-model="selectedValue"
    optionFilterProp="children"
    :filterOption="$commonFun.filterOption"
    showSearch
    placeholder="品牌"
    allow-clear
    style="width:100%"
  >
    <a-select-option
      v-for="(item, index) in allCompany"
      :key="'company-'+index"
      :value="item.value"
      :title="item.name"
    >{{ item.name }}</a-select-option>
  </a-select>
</template>
<script>
  import {mapState} from "vuex";

  export default {
    name:'CompanySelect',
    props: {
      value: {
        type: [String, Array, Object, undefined],
        default () {
          return undefined
        }
      },
      disabled: {
        type: Boolean,
        default: false
      },

    },
    data () {
      return {
      }
    },
    computed: {
      ...mapState({
        allCompany: (state) => state.dict.companyDictCode
      }),
      selectedValue:{
        get() {
          return this.value;
        },
        set(val) {
          this.$emit('input', val);    // 触发
          this.$emit('change', val);    // 触发
        }
      }
    },
    mounted() {
      this.$store.dispatch('getCompanyDictCodeData');
    }
  }
</script>